const request = function (url,method = "GET") {
	
	
	
	return new Promise((res,ref)=>{
		uni.showLoading({
			title:"Loading"
		})
		uni.request({
			url:url,
			method:method,
			success: (data) => {
				const result = data.data;
				const code = result.code;
				console.log(code)
				if(code == 200){
					res(result)
				}
				else{
					uni.showToast({
						title:result.msg || "Data Error"
					})
					ref("")
				}
				
			},
			fail: (error) => {
				uni.showToast({
					title:error.errMsg || "Data Error"
				})
				ref(error)
			},
			complete: () => {
				uni.hideLoading()
			}
		})
		
		
	})
}

export {request}